int[, ,] array3 = new int[ , , ] { { { 1, 2, 3 }}, { { 4, 5, 6 } } };请问[,,]这个里面怎么填数字?

来源:百度知道 编辑:UC知道 时间:2024/05/31 13:51:44
请问[,,]这个里面怎么填数字?

int[, ,] array3 = new int[,,] { { { 1, 2, 3 } }, { { 4, 5, 6 } } };
Console.WriteLine(array3.Rank);
用的好好的
C#允许这样的初始化方式
或者你直接一个等号等过去
int[, ,] array3 = { { { 1, 2, 3 } }, { { 4, 5, 6 } } };
又或者
int[, ,] array3 = new int[2, 1, 3];
然后赋值

给你看看英文原版,有例子和说明的
You can initialize an array of a primitive type to something besides 0 using this syntax:
int[] intArray = { 0, 3, 6, 9, 12, 15, 18, 21, 24, 27 };
Perhaps surprisingly, this single statement takes the place of both the reference
declaration and the use of new to create the array. The numbers within the curly braces
are called the initialization list. The size of the array is determined by the number of
values in this list.

int[, ,] array3 = new int[ , , ] { { { 1, 2, 3 }}, { { 4, 5, 6 } } };
这是错误形式